﻿using Assets.Scripts.Data;
using Assets.Scripts.Enums;
using Assets.Scripts.UI;
using Test30.Engine;
using UnityEngine;
using UnityEngine.UI;

namespace Assets.Scripts.App
{
    public class NewHeroScreen : Control
    {
        public NewHeroScreen() : base(UiType.Normal, UiMode.HideOther, Configs.UiPrefabsPath + Configs.PathConact + Configs.UiPrefabsNames.NewHeroScreen)
        {
            
        }

        public override void Init()
        {
            _content = Data as Content;

            GameObj.transform.Find("BackBtn").GetComponent<Button>()
                .onClick.AddListener(RunWelcomeScreen);

            GameObj.transform.Find("StartBtn").GetComponent<Button>()
                .onClick.AddListener(StartGame);
        }

        private void RunWelcomeScreen()
        {
            Ui.Close();
        }

        private void StartGame()
        {
            Hero hero = Hero.CreateTemp();

            Game game = new Game(hero, _content);

            TerminalForm.Get.CreateTerminal(game);

            TerminalForm.Get._Update();

            Ui.Run<PlayerInputControl>(game);

            Ui.Run<PlayGameScreen>(game);
        }


        private Content _content;

    }
}
